<?php


namespace app\noLogin\controller;
use app\BaseController;
use app\common\model\UserModel;
use app\common\util\SmsCode\impl\TestSmsCodeCodeImpl;
use think\App;

class Reg extends BaseController
{
    protected $userModel;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->userModel = new UserModel();
    }
    public function reg_do(){
        $params= request()->param();
        if (isset($params['account']))return $this->reg_do_by_account();
        if (isset($params['mobile']))return $this->reg_do_by_mobile();
        return R(false,[],"注册方式不存在");
    }
    public function reg_do_by_account()
    {
        $account = request()->param("account");
        $password = request()->param("password");
        $rs = $this->userModel->reg_do_by_account($account, $password);
        return R($rs, $rs, $this->userModel->getErr());
    }
    public function reg_do_by_mobile(){
        $mobile = request()->param("mobile");
        $password = request()->param("password");
        $smsCode = request()->param("smsCode");
        $smsSn = request()->param("smsSn");
        $rs = $this->userModel->reg_do_by_mobile($mobile,$password,$smsSn,$smsCode);
        return R($rs, $rs, $this->userModel->getErr());
    }
    public function send_sms(){
        $mobile = request()->param("mobile");
        $rsData=TestSmsCodeCodeImpl::send($mobile,"reg");
        return R($rsData);
    }
}